import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Button',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: FirstPage(),
    );
  }
}

class FirstPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    //定义文本样式

    return Scaffold(
      appBar: AppBar(
        title: Text("这是第一个页面"),
      ),
      body: Column(
        children: <Widget>[
          FlatButton(
            child: Text("跳转到第二个页面"),
            color: Colors.blue,
            onPressed: (){
              Navigator.push(context, new MaterialPageRoute(builder: (context) => new SecondPage()));
            },
          )
        ],
      ),
    );
  }

}


class SecondPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    //定义文本样式

    return Scaffold(
      appBar: AppBar(
        title: Text("这是第二个页面"),
      ),
      body: Column(
        children: <Widget>[
          FlatButton(
            child: Text("返回到第一个页面"),
            color: Colors.red,
            onPressed: (){
              Navigator.pop(context, new MaterialPageRoute(builder: (context) => new FirstPage()));
            },
          )
        ],
      ),
    );
  }

}